
package com.xbongbong.saas.domain.dao;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.aiassistant.domain.entity.AiProductEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.saas.domain.entity.ProductStockUpdateEntity;
import com.xbongbong.saas.domain.entity.ext.ProductEntityExt;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * ProductDao
 *
 * @author GuoJun.HU
 * @since V1.0
 * @date 2019/2/19 10:47
 */
public interface ProductDao {

    Integer insert(ProductEntityExt product);

    Integer insertBatch(@Param("list") List<ProductEntityExt> productList);

    Integer update(ProductEntityExt product);

    Integer deleteByKey(@Param("key") Long key, @Param("corpid") String corpid);
    /**
     * 批量删除
     * @param idIn 产品id列表
     * @param corpid 公司id
     * @return 删除行数
     */
    Integer deleteByIdIn(@Param("corpid") String corpid, @Param("idIn") List<Long> idIn);

    ProductEntityExt getByKey(@Param("key") Long key, @Param("corpid") String corpid);

    List<ProductEntityExt> findEntitys(@Param("param") Map<String, Object> param);

    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    List<Long> findIds(@Param("param") Map<String, Object> param);

    List<Long> findWarningProductIds(@Param("param") Map<String, Object> modelMap);

    /**
     * 批量更新
     * @param list 数据列表
     * @param corpid 公司id
     * @return
     */
    Integer updateBatch(@Param("list") List<UpdateDataEntity> list,@Param("corpid") String corpid);

    /**
     * 获取智能助手需要的产品数据
     *
     * @param corpid 公司id
     * @param idIn 数据ids
     * @return
     * @throws
     * @author hongxiao
     * @date: 2020-02-24 16:54
     * @since v4.13.0
     * @version v4.13.0
     */
    List<AiProductEntity> getProductList4Ai(@Param("corpid") String corpid, @Param("idIn") List<Long> idIn);

    Integer updateBatchSerialNo(@Param("list")List<UpdateDataEntity> list);

    List<String> getCorpidList();

    void updateStockDB(@Param("idIn") Set<Long> keySet, @Param("list") Collection<ProductStockUpdateEntity> values, @Param("corpid") String corpid);

    void updateWarehouse(@Param("list") Set<Long> keySet, @Param("idMap") Map<Long, JSONObject> warehouseIdMap, @Param("corpid") String corpid);

    List<PaasFormDataEntityExt> findEntitysByPaas(@Param("param") Map<String, Object> param);

    void updateProductCostByid(@Param("list")List<ProductEntityExt> productEntityExtList , @Param("corpid")String corpid);

    List<ProductEntityExt> getCostIsNullProduct(@Param("corpid")String corpid);
}